package com.hfi.controller;

import com.hfi.model.Employee;
import com.hfi.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author ChangLiang
 * @date 2019/5/28
 */
@Controller
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping("addEmp")
    @ResponseBody
    public int addEmp(@RequestBody Employee employee) {
        return employeeService.addEmp(employee);
    }

    @PostMapping("updateEmp")
    @ResponseBody
    public int updateEmp(@RequestBody Employee employee) {
        return employeeService.updateEmp(employee);
    }



    @GetMapping("/getEmployeeById")
    @ResponseBody
    public Employee getEmployeeById(@RequestParam Integer id) {
        return employeeService.getEmployeeById(id);
    }

    @PostMapping("/selectOneEmployee")
    @ResponseBody
    public Employee selectOneEmployee(@RequestBody Employee employee) {
        return employeeService.selectOneEmployee(employee);
    }

    @PostMapping("/selectBatchIdsEmployee")
    @ResponseBody
    public List<Employee> selectBatchIdsEmployee(@RequestParam("ids[]") List<Integer> idList) {
        return employeeService.selectBatchIdsEmployee(idList);
    }

    /**
     * 可以进行多条件查询
     * @param map
     * @return
     */
    @PostMapping("/selectByMapEmployee")
    @ResponseBody
    public List<Employee> selectByMapEmployee(@RequestParam Map<String,Object> map) {
        return employeeService.selectByMapEmployee(map);
    }

    @PostMapping("/selectPageEmployee")
    @ResponseBody
    public List<Employee> selectPageEmployee(@RequestBody Employee employee) {
        return employeeService.selectPageEmployee(employee);
    }

    @PostMapping("/selectPageEntityMapper")
    @ResponseBody
    public List<Employee> selectPageEntityMapper(@RequestBody Employee employee) {
        return employeeService.selectPageEntityMapper(employee);
    }

    @PostMapping("updateEmpEntityMapper")
    @ResponseBody
    public Integer updateEmpEntityMapper(@RequestBody Employee employee) {
        return employeeService.updateEmpEntityMapper(employee);
    }
}
